<template>
  <div class="app-container">
    <!--地图div-->
    <div style="position:absolute;top:0px;left:0px;width:100%;height:100%;">
      <SecondaryMap
          :queryMapBool="queryMapBool"
          :mapExtent="mapExtent"
          @showQueryMapDraw="showQueryMapDraw"
      ></SecondaryMap>
    </div>
    <!--index页面div-->
    <div id="secondaryMapDiv" class="ol-popup">
        <el-button type="primary" @click="handleAssess" style="margin:20px;">评估</el-button>

        <div class="showAssess" v-if="openAssess">
            <p>评估内容</p>
            <el-radio-group v-model="content" @change="changeRadio">
                <el-radio label="危险源分布图">危险源分布图</el-radio>
                <el-radio label="危险源避让分布图">危险源避让分布图</el-radio>
                <el-radio label="地震地质灾害隐患点分布图">地质灾害隐患点分布图</el-radio>
            </el-radio-group>
            <p>设定评估范围
                <el-radio-group v-model="view" style="margin-left:20px">
                    <!--zyt修改-->
                    <el-radio label="手动选择" @click="clearQueryMapClick">手动选择</el-radio>
                    <el-radio label="地图圈选" @click="queryMapClick">地图圈选</el-radio>
                </el-radio-group>
            </p>
            <template v-if="view=='手动选择'">
                <template v-if="type == 1">
                    <el-cascader ref="departmentTree" :options="options" :props="props" collapse-tags clearable
                        collapse-tags-tooltip @change="departmentChange" />
                </template>
                <template v-else-if="type == 2">
                    <el-cascader ref="departmentTree" :options="options1" :props="props1" collapse-tags clearable
                        collapse-tags-tooltip @change="departmentChange" />
                </template>
            </template>
            <template v-else></template>
            <div class="footer">
                <!--zyt修改-->
                <el-button type="primary" @click="openAssess = false">取消</el-button>
                <el-button type="primary" @click="setParameter"
                           :disabled="(view == '手动选择' && selectValue.length == 0) || (view == '地图圈选' && queryMapDrawResult.leftX==null)"
                >设定参数</el-button>
            </div>
        </div>

        <el-dialog v-if="openParameter" v-model="openParameter" width="650px" title="设定参数" append-to-body>
            <p></p>
            <el-form ref="assessRef" :model="queryParams" :rules="rules" label-width="140px">
                <el-row>
                    <el-col :span="20" v-if="content == '危险源避让分布图'">
                        <el-form-item label="加油站数据" prop="jyzDataVersion">
                            <SelectVersion v-model="queryParams.jyzDataVersion" :list="selectValueId"
                                title="加油站数据" num="jyjqz1" name="jyzDataVersion" @getSelecVersion="getSelecVersion"></SelectVersion>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4" v-if="content == '危险源避让分布图'">
                        <p style="color:red;margin: 7px 0;cursor: pointer;" @click="handleExplain">公式说明</p>
                    </el-col>
                    <el-col :span="24" v-if="content == '危险源分布图'">
                        <el-form-item label="加油站数据" prop="jyzDataVersion">
                            <SelectVersion v-model="queryParams.jyzDataVersion" :list="selectValueId"
                                title="加油站数据" num="jyjqz1" name="jyzDataVersion" @getSelecVersion="getSelecVersion"></SelectVersion>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24" v-if="content == '危险源避让分布图'||content == '危险源分布图'">
                        <el-form-item label="储气罐数据" prop="cqgDataVersion">
                            <SelectData v-model="queryParams.cqgDataVersion" :list="selectValueId" title="储气罐数据版本" @getCqgDataVersion="getCqgDataVersion">
                            </SelectData>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24" v-if="content == '危险源避让分布图'||content == '危险源分布图'">
                        <el-form-item label="危化企业数据" prop="whqyDataVersion">
                            <SelectVersion v-model="queryParams.whqyDataVersion" :list="selectValueId"
                                title="危化企业数据" num="whqy1" name="whqyDataVersion" @getSelecVersion="getSelecVersion"></SelectVersion>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24" v-if="content == '地震地质灾害隐患点分布图'">
                        <el-form-item label="地震灾害危险点" prop="dzzhDataVersion">
                            <SelectVersion v-model="queryParams.dzzhDataVersion" :list="selectValueId"
                                title="地震灾害危险点" num="dzzhwxd" name="dzzhDataVersion" @getSelecVersion="getSelecVersion"></SelectVersion>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="图件模板" prop="tjmb">
                            <el-select v-model="queryParams.tjmb" style="width:100%" placeholder="请选择">
                                <template v-if="content == '危险源分布图'">
                                    <el-option v-for="item in option1" :key="item.id" :label="item.name"
                                        :value="item.id">
                                    </el-option>
                                </template>
                                <template v-else-if="content == '危险源避让分布图'">
                                    <el-option v-for="item in option2" :key="item.id" :label="item.name"
                                        :value="item.id">
                                    </el-option>
                                </template>
                                <template v-else>
                                    <el-option v-for="item in option3" :key="item.id" :label="item.name"
                                        :value="item.id">
                                    </el-option>
                                </template>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12"></el-col>
                    <el-col :span="12">
                        <el-form-item label="制图单位" prop="ztdw">
                            <el-input v-model="queryParams.ztdw" placeholder="请输入制图单位" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12"></el-col>
                    <el-col :span="12" v-if="openParameter">
                        <el-form-item label="图件标题" prop="tjbt">
                            <el-input v-model="queryParams.tjbt" placeholder="请输入图件标题" />
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <template #footer>
                <div class="dialog-footer">
                    <el-button type="primary" @click="openParameter = false">退出</el-button>
                    <el-button type="primary" @click="toAssess">评估</el-button>
                </div>
            </template>
        </el-dialog>

        <el-dialog title="结果查看" v-if="openPic" v-model="openPic" width="600px" append-to-body>
            <el-form ref="picRef" label-width="120px" :model="form" :rules="rules">
                <el-row style="margin: 20px 0;">
                    <el-col style="margin-bottom: 10px;">
                        <ImagePreview :src="`/attachment/downLoad?attachId=${form.attach.attachId}`"></ImagePreview>
                        <!-- <img :src="baseUrl + form.attach.attachId" :alt="baseUrl + form.attach.attachId"
                            style="width:100%" /> -->
                    </el-col>
                    <el-col v-if="steps == 1">
                        <el-form-item label="标题" prop="title">
                            <el-input v-model="form.title" placeholder="请输入标题" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12" v-if="steps == 3">
                        <el-form-item label="图件模板" prop="tjmb">
                            <el-select v-model="form.tjmb" style="width:100%" placeholder="请选择">
                                <template v-if="content == '危险源分布图'">
                                    <el-option v-for="item in option1" :key="item.id" :label="item.name"
                                        :value="item.id">
                                    </el-option>
                                </template>
                                <template v-else-if="content == '危险源避让分布图'">
                                    <el-option v-for="item in option2" :key="item.id" :label="item.name"
                                        :value="item.id">
                                    </el-option>
                                </template>
                                <template v-else>
                                    <el-option v-for="item in option3" :key="item.id" :label="item.name"
                                        :value="item.id">
                                    </el-option>
                                </template>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12"></el-col>
                    <el-col>
                        <el-radio-group v-model="steps">
                            <el-radio :label="1">保存结果</el-radio>
                            <el-radio :label="2">重新设定参数</el-radio>
                            <el-radio :label="3">更换图件模板</el-radio>
                        </el-radio-group>
                    </el-col>
                </el-row>
            </el-form>
            <template #footer>
                <div class="dialog-footer">
                    <el-button type="primary" @click="saves">确 定</el-button>
                    <el-button @click="openPic = false">取 消</el-button>
                </div>
            </template>
        </el-dialog>

        <el-dialog v-model="openExplain" width="650px" :title="content + '模型'" append-to-body>
            <p></p>
            <el-row>
                <el-col class="tab-title">{{ content }}模型</el-col>
                <el-col>
                    <span
                        class="indent">根据次生灾害危险源（次生灾害数据管理子模块）的分布和相关的属性信息进行次生灾害隐患评估，次生灾害影响评估采用经验统计法，危害等级评估如表所示：</span><br />
                </el-col>
                <el-col>
                    <table class="tableBorder">
                        <tr>
                            <th>危险品类型</th>
                            <th>储量</th>
                            <th>周边环境、防护<br />否达标</th>
                            <th>危害等级</th>
                            <th>影响半径<br />(m)</th>
                        </tr>
                        <tr>
                            <td rowspan="8">汽油、柴油</td>
                            <td>[0,30)m<sup>3</sup></td>
                            <td>是/否</td>
                            <td>危机本体(III级)</td>
                            <td>50</td>
                        </tr>
                        <tr>
                            <td>[30,60)m<sup>3</sup></td>
                            <td>是</td>
                            <td>危机本体(III级)</td>
                            <td>50</td>
                        </tr>
                        <tr>
                            <td>[30,60)m<sup>3</sup></td>
                            <td>否</td>
                            <td>危机本体(III级)</td>
                            <td>100</td>
                        </tr>
                        <tr>
                            <td>[60,120)m<sup>3</sup></td>
                            <td>是</td>
                            <td>危机本体(III级)</td>
                            <td>100</td>
                        </tr>
                        <tr>
                            <td>[60,120)m<sup>3</sup></td>
                            <td>否</td>
                            <td>影响近邻(II级)</td>
                            <td>200</td>
                        </tr>
                        <tr>
                            <td>[120,300)m<sup>3</sup></td>
                            <td>是</td>
                            <td>影响近邻(II级)</td>
                            <td>200</td>
                        </tr>
                        <tr>
                            <td>[120,300)m<sup>3</sup></td>
                            <td>否</td>
                            <td>蔓延成片(I级)</td>
                            <td>300</td>
                        </tr>
                        <tr>
                            <td>≥300m<sup>3</sup></td>
                            <td>是/否</td>
                            <td>蔓延成片(I级)</td>
                            <td>300</td>
                        </tr>
                        <tr>
                            <td rowspan="8">燃气、液化气</td>
                            <td>[0,200)m<sup>3</sup></td>
                            <td>是/否</td>
                            <td>危机本体(III级)</td>
                            <td>50</td>
                        </tr>
                        <tr>
                            <td>[200,500)m<sup>3</sup></td>
                            <td>是</td>
                            <td>危机本体(III级)</td>
                            <td>50</td>
                        </tr>
                        <tr>
                            <td>[200,500)m<sup>3</sup></td>
                            <td>否</td>
                            <td>危机本体(III级)</td>
                            <td>100</td>
                        </tr>
                        <tr>
                            <td>[500,1000)m<sup>3</sup></td>
                            <td>是</td>
                            <td>危机本体(III级)</td>
                            <td>100</td>
                        </tr>
                        <tr>
                            <td>[500,1000)m<sup>3</sup></td>
                            <td>否</td>
                            <td>影响近邻(II级)</td>
                            <td>200</td>
                        </tr>
                        <tr>
                            <td>[1000,3000)m<sup>3</sup></td>
                            <td>是</td>
                            <td>影响近邻(II级)</td>
                            <td>200</td>
                        </tr>
                        <tr>
                            <td>[1000,3000)m<sup>3</sup></td>
                            <td>否</td>
                            <td>蔓延成片(I级)</td>
                            <td>300</td>
                        </tr>
                        <tr>
                            <td>≥3000m<sup>3</sup></td>
                            <td>是/否</td>
                            <td>蔓延成片(I级)</td>
                            <td>300</td>
                        </tr>
                        <tr>
                            <td rowspan="8">易燃易爆<br /> 体、液体</td>
                            <td>[0,100)m<sup>3</sup></td>
                            <td>是/否</td>
                            <td>危机本体(III级)</td>
                            <td>50</td>
                        </tr>
                        <tr>
                            <td>[100,300)m<sup>3</sup></td>
                            <td>是</td>
                            <td>危机本体(III级)</td>
                            <td>50</td>
                        </tr>
                        <tr>
                            <td>[100,300)m<sup>3</sup></td>
                            <td>否</td>
                            <td>危机本体(III级)</td>
                            <td>100</td>
                        </tr>
                        <tr>
                            <td>[300,800)m<sup>3</sup></td>
                            <td>是</td>
                            <td>危机本体(III级)</td>
                            <td>150</td>
                        </tr>
                        <tr>
                            <td>[300,800)m<sup>3</sup></td>
                            <td>否</td>
                            <td>影响近邻(II级)</td>
                            <td>200</td>
                        </tr>
                        <tr>
                            <td>[800,1500)m<sup>3</sup></td>
                            <td>是</td>
                            <td>影响近邻(II级)</td>
                            <td>300</td>
                        </tr>
                        <tr>
                            <td>[800,1500)m<sup>3</sup></td>
                            <td>否</td>
                            <td>蔓延成片(I级)</td>
                            <td>500</td>
                        </tr>
                        <tr>
                            <td>≥1500m<sup>3</sup></td>
                            <td>是/否</td>
                            <td>蔓延成片(I级)</td>
                            <td>500</td>
                        </tr>
                        <tr>
                            <td rowspan="8">易燃易爆<br />固体</td>
                            <td>[0,30)m<sup>3</sup></td>
                            <td>是/否</td>
                            <td>危机本体(III级)</td>
                            <td>50</td>
                        </tr>
                        <tr>
                            <td>[30,60)m<sup>3</sup></td>
                            <td>是</td>
                            <td>危机本体(III级)</td>
                            <td>50</td>
                        </tr>
                        <tr>
                            <td>[30,60)m<sup>3</sup></td>
                            <td>否</td>
                            <td>危机本体(III级)</td>
                            <td>100</td>
                        </tr>
                        <tr>
                            <td>[60,120)m<sup>3</sup></td>
                            <td>是</td>
                            <td>危机本体(III级)</td>
                            <td>150</td>
                        </tr>
                        <tr>
                            <td>[60,120)m<sup>3</sup></td>
                            <td>否</td>
                            <td>影响近邻(II级)</td>
                            <td>200</td>
                        </tr>
                        <tr>
                            <td>[120,300)m<sup>3</sup></td>
                            <td>是</td>
                            <td>影响近邻(II级)</td>
                            <td>300</td>
                        </tr>
                        <tr>
                            <td>[120,300)m<sup>3</sup></td>
                            <td>否</td>
                            <td>蔓延成片(I级)</td>
                            <td>500</td>
                        </tr>
                        <tr>
                            <td>≥300m<sup>3</sup></td>
                            <td>是/否</td>
                            <td>蔓延成片(I级)</td>
                            <td>500</td>
                        </tr>
                        <tr>
                            <td rowspan="8">其他</td>
                            <td>类型（小型）</td>
                            <td>是</td>
                            <td>危机本体(III级)</td>
                            <td>50</td>
                        </tr>
                        <tr>
                            <td>类型（小型）</td>
                            <td>否</td>
                            <td>影响近邻(II级)</td>
                            <td>100</td>
                        </tr>
                        <tr>
                            <td>类型（中型）</td>
                            <td>是</td>
                            <td>影响近邻(II级)</td>
                            <td>100</td>
                        </tr>
                        <tr>
                            <td>类型（中型）</td>
                            <td>否</td>
                            <td>影响近邻(II级)</td>
                            <td>200</td>
                        </tr>
                        <tr>
                            <td>类型（大型）</td>
                            <td>是</td>
                            <td>影响近邻(II级)</td>
                            <td>200</td>
                        </tr>
                        <tr>
                            <td>类型（大型）</td>
                            <td>否</td>
                            <td>蔓延成片(I级)</td>
                            <td>300</td>
                        </tr>
                    </table>
                </el-col>
            </el-row>
            <template #footer>
                <div class="dialog-footer">
                    <el-button @click="openExplain = false">退出</el-button>
                </div>
            </template>
        </el-dialog>
    </div>
  </div>
</template>

<script setup>
//地图
import SecondaryMap from '@/map/assess/secondary/map.vue';
import { titleCheck } from "@/api/assess/secondary";
import { ElMessage, ElMessageBox } from 'element-plus';
import { sourceOfDanger, destructionAssess, destructionAssess1, getPicReport, uploadHouse } from "@/api/assess/map/secondary"
import SelectVersion from "@/components/SelectVersion"
import SelectData from "@/components/SelectData"
import { getImport,getExtentByIaId } from "@/api/business/activities";
import { getProvince, getChildArea } from "@/api/system/division";
const baseUrl = import.meta.env.VITE_APP_BASE_API + "/attachment/downLoad?attachId=";
const route = useRoute();
const { proxy } = getCurrentInstance();
const openAssess = ref(false);
const openParameter = ref(false);
const openExplain = ref(false);
const areaData = ref([]);
const province = ref();
const provinceId = ref();
const city = ref();
const cityId = ref();
const counties = ref();
const countiesId = ref();
const selectValue = ref([]);
const selectValueId = ref([]);
const openPic = ref(false);
const option1 = ref([]);;
const option2 = ref([]);
const option3 = ref([]);
const steps = ref(1);
const content = ref('危险源分布图');
const view = ref('手动选择')

const type = ref(1);
const options1 = ref({});
const props1 = ref({ multiple: true });
const options = ref({});
const props = ref({
    multiple: true,
    lazy: true,
    lazyLoad(node, resolve) {
        const { level } = node
        if (level === 0) {  // 第一级加载省份
            getChildArea(node.data.value).then(res => {
                if (res.code === 200) {
                    const nodes = res.data.map(item => {
                        return {
                            label: item.name,
                            value: item.id,
                            leaf: false
                        }
                    })
                    resolve(nodes)
                }
            })
        } else if (level === 1) {  //  第二级加载城市
            getChildArea(node.data.value)
                .then(res => {
                    if (res.code === 200) {
                        const nodes = res.data.map(item => {
                            return {
                                label: item.name,
                                value: item.id,
                                leaf: false
                            }
                        })
                        resolve(nodes)
                    }
                })
        } else {
            getChildArea(node.data.value)
                .then(res => {
                    if (res.code === 200) {
                        const nodes = res.data.map(item => {
                            return {
                                label: item.name,
                                value: item.id,
                                leaf: true
                            }
                        })
                        resolve(nodes)
                    }
                })
        }
    }
});

const titleName = (rule, value, callback) => {
    if (!value) {
        callback(new Error('请输入标题'))
    } else if (value) {
        const parmas = { ssdRelation: route.query.id, ssdImageTitle: value,ssdContent:content.value }
        titleCheck(parmas).then(res => {
            if (!res.data) {
                callback()
            } else {
                callback(new Error("该标题已存在，请重新输入"))
            }
        }).catch(_ => {
            callback(new Error(_.message))
        })
    }
}

const data = reactive({
    queryParams: {
        dataVersion: '',
        tjmb: '',
        ztdw: '',
    },
    form: {},
    rules: {
        jyzDataVersion: [{ required: true, message: "加油站数据不能为空", trigger: "change" }],
        cqgDataVersion: [{ required: true, message: "储气罐数据不能为空", trigger: "change" }],
        whqyDataVersion: [{ required: true, message: "危化企业数据不能为空", trigger: "change" }],
        dzzhDataVersion: [{ required: true, message: "地震灾害危险点不能为空", trigger: "change" }],
        tjmb: [{ required: true, message: "图件模板不能为空", trigger: "change" }],
        ztdw: [{ required: true, message: "制图单位不能为空", trigger: "blur" }],
        title: [{ required: true, validator: titleName, trigger: "blur" }],
        tjbt: [{ required: true, message: "图件标题不能为空", trigger: "blur" }],
    }
})

const { queryParams, form, rules } = toRefs(data)

function handleExplain() {
    openExplain.value = true;
}
function handleAssess() {
    reset1();
    content.value = '危险源分布图';
    openAssess.value = !openAssess.value;
}
function changeRadio() {
    reset1();
}

function reset1() {
    selectValue.value = [];
    selectValueId.value = [];
}

function departmentChange() {
    let node = proxy.$refs['departmentTree'].getCheckedNodes();
    let arr = [];
    let arr1 = [];
    node.forEach(item => {
        if (item.pathLabels[2]) {
            arr.push({ province: item.pathLabels[0], city: item.pathLabels[1], prefecture: item.pathLabels[2] })
            arr1.push({ provinceId: item.pathValues[0], cityId: item.pathValues[1], prefectureId: item.pathValues[2] })
        }
    })
    selectValue.value = arr;
    selectValueId.value = arr1;
}

function setParameter() {
    openAssess.value = false;
    openParameter.value = true;
    proxy.resetForm("assessRef");
    queryParams.value.tjmb = undefined;
    queryParams.value.ztdw = undefined;
    queryParams.value.tjbt = undefined;
    queryParams.value.jyzDataVersion = undefined;
    queryParams.value.cqgDataVersion = undefined;
    queryParams.value.whqyDataVersion = undefined;
    queryParams.value.dzzhDataVersion = undefined;
}
function getSelecVersion(obj){
    queryParams.value[obj.name] = obj.code;
    proxy.$refs['assessRef'].clearValidate(obj.name)
}
function toAssess() { // 评估
    proxy.$refs["assessRef"].validate(valid => {
        if (valid) {
            proxy.$modal.loading("正在评估，请稍候...");
            if (content.value == '危险源分布图') {
                sourceOfDanger({ ...queryParams.value, list: selectValue.value, iaId: route.query.id, circleVO:queryMapDrawResult.value  }).then(res => {
                    finish(res);
                }).catch(() => {
                    proxy.$modal.closeLoading();
                })
            } else if (content.value == '危险源避让分布图') {
                destructionAssess({ ...queryParams.value, list: selectValue.value, iaId: route.query.id, circleVO:queryMapDrawResult.value  }).then(res => {
                    finish(res);
                }).catch(() => {
                    proxy.$modal.closeLoading();
                })
            } else {
                destructionAssess1({ ...queryParams.value, list: selectValue.value, iaId: route.query.id, circleVO:queryMapDrawResult.value  }).then(res => {
                    finish(res);
                }).catch(() => {
                    proxy.$modal.closeLoading();
                })
            }

        }
    });
}

function finish(res) {
    openParameter.value = false;
    proxy.$modal.closeLoading();
    ElMessageBox.alert('评估完成，查看结果！', '消息提示', {
        confirmButtonText: '确定',
        type: "success",
        callback: () => {
            openPic.value = true;
            proxy.resetForm("picRef");
            steps.value == 1;
            form.value = res.data;
        },
    })
}

function getCqgDataVersion(value){
    queryParams.value.cqgDataVersion = value;
}

function saves() {
    if (steps.value == 1) {
        openParameter.value = false;
        proxy.$refs["picRef"].validate(valid => {
            if (valid) {
                form.value.ssdImageId = form.value.attach.attachId;
                form.value.ssdContent = form.value.count;
                form.value.ssdImageTitle = form.value.title;
                form.value.dataMessage = form.value.dataVersion;
                uploadHouse({ ...form.value, ssdRelation: route.query.id }).then(response => {
                    proxy.$modal.msgSuccess("上传成功");
                    openPic.value = false;
                }).catch(() => { });
            }
        });
    } else if (steps.value == 2) {
        openPic.value = false;
        openParameter.value = true;
    } else {
        openParameter.value = false;
        if (content.value == '危险源分布图') {
            proxy.$refs["picRef"].validate(valid => {
                if (valid) {
                    proxy.$modal.loading("正在评估，请稍候...");
                    sourceOfDanger({ ...queryParams.value, tjmb: form.value.tjmb, list: selectValue.value, iaId: route.query.id }).then(res => {
                        finish(res);
                    }).catch(() => {
                        proxy.$modal.closeLoading();
                    })
                }
            });
        } else if (content.value == '危险源避让分布图') {
            proxy.$refs["picRef"].validate(valid => {
                if (valid) {
                    proxy.$modal.loading("正在评估，请稍候...");
                    destructionAssess({ ...queryParams.value, tjmb: form.value.tjmb, list: selectValue.value, iaId: route.query.id }).then(res => {
                        finish(res);
                    }).catch(() => {
                        proxy.$modal.closeLoading();
                    })
                }
            });
        } else {
            proxy.$refs["picRef"].validate(valid => {
                if (valid) {
                    proxy.$modal.loading("正在评估，请稍候...");
                    destructionAssess1({ ...queryParams.value, tjmb: form.value.tjmb, list: selectValue.value, iaId: route.query.id }).then(res => {
                        finish(res);
                    }).catch(() => {
                        proxy.$modal.closeLoading();
                    })
                }
            });
        }
    }
}
function getCity() {
    getImport(route.query.id).then(res => {
        province.value = res.data.importantActivity.iaProvince;
        provinceId.value = res.data.importantActivity.provinceId;
        city.value = res.data.importantActivity.iaCity;
        cityId.value = res.data.importantActivity.cityId;
        counties.value = res.data.importantActivity.iaCounties;
        countiesId.value = res.data.importantActivity.countiesId;
        if (!city.value && !counties.value) {
            type.value = 1;
            options.value = [{
                label: province.value,
                value: provinceId.value,
                leaf: false,
            }]
        }
        if (counties.value) {
            type.value = 2;
            options1.value = [{
                label: province.value,
                value: provinceId.value,
                leaf: false,
                children: [{
                    label: city.value,
                    value: cityId.value,
                    leaf: false,
                    children: [{
                        label: counties.value,
                        value: countiesId.value,
                        leaf: true
                    }]
                }]
            }]
        }
        if (city.value && !counties.value) {
            type.value = 2;
            getChildArea(cityId.value).then(response => {
                areaData.value = response.data;
                areaData.value.forEach(item => {
                    item.value = item.id;
                    item.label = item.name;
                    item.leaf = true;
                });
                options1.value = [{
                    label: province.value,
                    value: provinceId.value,
                    leaf: false,
                    children: [{
                        value: cityId.value,
                        label: city.value,
                        leaf: false,
                        children: areaData.value
                    }]
                }]
            });

        }
    })
}
function getType(num) {
    getPicReport(num).then(res => {
        if (num == 5) {
            option1.value = res.data
        } else if (num == 15) {
            option2.value = res.data
        } else if (num == 6) [
            option3.value = res.data
        ]
    })
}



//地图传参--start
const queryMapBool = ref(false);//是否开启地图圈选
//地图圈选结果参数
const queryMapDrawResult = ref({
  leftX:null,
  leftY:null,
  rightX:null,
  rightY:null,
  centerX:null,
  centerY:null,
});
//地图圈选
const queryMapClick = ()=>{
  queryMapBool.value = false;//关闭地图圈选
  //清空行政区划选择
  selectValue.value = [];
  selectValueId.value = [];
  nextTick(() => {
    queryMapBool.value = true;//开启地图圈选
  });
}
//关闭地图圈选
const clearQueryMapClick = ()=>{
  queryMapBool.value = false;//关闭地图圈选
  //清空地图圈选结果参数
  queryMapDrawResult.value = {
    leftX:null,
    leftY:null,
    rightX:null,
    rightY:null,
    centerX:null,
    centerY:null,
  }
}
//地图圈选结果
const showQueryMapDraw = (array)=>{
  console.log("地图圈选结果");
  console.log(array);
  let polygonWkt = array[0];
  let extent = array[1];
  let center = array[2];
  queryMapDrawResult.value = {
    leftX:extent[0],
    leftY:extent[1],
    rightX:extent[2],
    rightY:extent[3],
    centerX:center[0],
    centerY:center[1],
  }
}

//获取活动行政区划的范围
const mapExtent = ref([]);
function getMapExtentByIaId() {
  getExtentByIaId(route.query.id).then(res => {
    let data = res.data;
    console.log(data);
    //BOX(113.51660441700005 37.43676435400005,115.47735626200006 38.76359765400008)
    if(data.indexOf("BOX(")!=-1){
      //mapExtent.value = [113.51660441700005, 37.43676435400005,115.47735626200006, 38.76359765400008];
      let arr = data.split("BOX(")[1].split(")")[0].split(",");
      if(arr.length==2){
        let leftBottom = arr[0].split(" ");
        let rightTop = arr[1].split(" ");
        if(leftBottom.length==2 && rightTop.length==2){
          let left = Number(leftBottom[0]);
          let bottom = Number(leftBottom[1]);
          let right = Number(rightTop[0]);
          let top = Number(rightTop[1]);
          mapExtent.value = [left,bottom,right,top];
        }
      }
    }
  });
}
getMapExtentByIaId();
//地图传参--end


getType(5);
getType(15)
getType(6)
getCity();
</script>

<style lang="scss" scoped>
.tableBorder{
    margin-top: 20px;
    width: 100%;
    border-collapse:collapse;
    td,th{
        border:1px solid #ccc;
        padding: 5px;
        text-align: center;
    }
}
:deep(.el-transfer__buttons) {
    padding: 0 10px;

    .el-transfer__button {
        margin: 15px 0;
        display: block;
    }

    .el-transfer__button:nth-child(2) {
        margin-left: 0px;
    }

    .el-button+.el-button {
        margin-left: 0px;
    }
}

.showAssess {
    position: absolute;
    top: 20px;
    left: 80px;
    width: 536px;
    padding: 20px;
    background: rgba($color: #fff, $alpha: 0.7);//zyt修改
    border: 1px solid #000;

    p {
        font-weight: bold;
    }
}

.footer {
    text-align: center;
    margin-top: 20px;
}

.tab-title {
    font-size: 16px;
    font-weight: bold;
    border-left: 4px solid #0D9AFF;
    font-family: PingFangSC-Medium;
    padding-left: 10px;
    margin-bottom: 20px;
}

.indent {
    display: inline-block;
    text-indent: 2em;
}
</style>